<?php
namespace app\api\middleware;

use Webman\MiddlewareInterface;
use Webman\Http\Response;
use Webman\Http\Request;

class Lang implements MiddlewareInterface
{
    public function process(Request $request, callable $handler) : Response
    {
         
    	$session = $request->session();
        $lang = $session->get('lang', 'zh_CN');
    	if($request->get("lang")){
            $lang = $request->get("lang");
    		$session->set('lang', $lang);
    	}
        locale($lang);
       
        return $handler($request);
    }
}